using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using System.Collections;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace WindowsGame
{
    class ShotManager
    {
        List<Shot> mShotList = new List<Shot>();
        Shot mShot;
        float mTotalElapsed = 0;
        float mFireRate = 0.01f;

        public int ShotCount()
        {
            return mShotList.Count;
        }

        public void Add(Vector2 startPosition, Texture2D texture, Vector2 movement, float elapsed)
        {
            this.mTotalElapsed += elapsed;

            if (this.mTotalElapsed > this.mFireRate)
            {
                this.mTotalElapsed -= this.mFireRate;
                mShot = new Shot(startPosition, texture, movement);
                mShotList.Add(mShot);
            }
        }

        public void Update(TileMap map, CharacterObject player)
        {
            foreach (Shot shot in mShotList)
            {
                shot.Update(map, player);
            }

            List<Shot> mTempShotList = new List<Shot>();

            foreach (Shot shot in mShotList)
            {
                if (shot.Remove == false)
                {
                    mTempShotList.Add(shot);
                }
            }

            mShotList = mTempShotList;
        }

        public void Draw(SpriteBatch batch)
        {
            foreach (Shot shot in mShotList)
            {
                shot.Draw(batch);
            }
        }
    }
}
